package uni.androidgame;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;

public class GameConsole
{
    private static String[] messages = new String[1000];
    private static Point _position;
    private static final int _linesToShow = 3;
    private static int messagesAdded = 0;
    private static Paint _textPaint;

    public static void setup(int x, int y)
    {
        _position = new Point(x,y);
        _textPaint = new Paint();
        _textPaint.setColor(Color.WHITE);
        _textPaint.setTextSize(20);
    }
    public static void addMessage(String message)
    {
        messages[messagesAdded] = message;
        messagesAdded++;
    }
    public static void draw(Canvas canvas)
    {
        if(messagesAdded<_linesToShow)
        {
            for(int i = 0;i<messagesAdded;i++)
            {
                canvas.drawText(messages[i],_position.x,_position.y+30*i,_textPaint);
            }
        }
        else
        {
            for(int i = 0;i<_linesToShow;i++)
            {
                canvas.drawText(messages[(messagesAdded-_linesToShow)+i],_position.x,_position.y+30*i,_textPaint);
            }
        }

    }
}
